﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Core.Framework.Interceptors.Interfaces
{
    /// <summary>
    /// 事务接口，使用不同的ORM实现此接口可实现声明式事务
    /// </summary>
    public interface ITransaction
    {
        /// <summary>
        /// 获取当前事务Id
        /// </summary>
        /// <returns></returns>
        string GetCurrentTransactionId();
        /// <summary>
        /// 当前是否已经开启事务
        /// </summary>
        /// <returns></returns>
        bool HasTransaction();
        /// <summary>
        /// 开始事务
        /// </summary>
        void BeginTransaction();
        /// <summary>
        /// 提交事务
        /// </summary>
        void CommitTransaction();
        /// <summary>
        /// 回滚事务
        /// </summary>
        void RollBackTransation();
        /// <summary>
        /// 异步提交事务
        /// </summary>
        /// <returns></returns>
        Task CommitTransactionAsync();
        /// <summary>
        /// 异步开始事务
        /// </summary>
        /// <returns></returns>
        Task BeginTransactionAsync();
        /// <summary>
        /// 异步回滚事务
        /// </summary>
        /// <returns></returns>
        Task RollBackTransationAsync();
    }
}
